<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%String contextRoot = request.getContextPath();%>
<f:loadBundle basename="properties.messages" var="msg" />
<f:view>
<!doctype html>
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <title>SISDEP : Sistema de Informaci<h:outputText value="#{msg.tilde_o}" />n de Espacio P<h:outputText value="#{msg.tilde_u}" />blico</title>
	<meta name="description" content="" />
	<meta name="author" content="" />		     
	<link rel="stylesheet" href="<%=contextRoot%>/css/validationEngine.jquery.css" type="text/css">
	<link rel="stylesheet" href="<%=contextRoot%>/css/template.css" type="text/css">
	<link rel="stylesheet" href="<%=contextRoot%>/css/normalize.css">
	<link rel="stylesheet" href="<%=contextRoot%>/css/uniform.css"> <!-- estilos formularios -->
	<link rel="stylesheet" href="<%=contextRoot%>/css/cuerpo.css">	
	<link rel="stylesheet" href="<%=contextRoot%>/css/richCustom.css">	
</head>
<body>
<div id="marco"> <!--inicio contenedor --> 
<div class="arriba-cuerpo"></div> 
<div class="cuerpo">
<a href="<%=contextRoot%>/index.jsf"><img src="<%= contextRoot %>/images/logos.png" /></a>
<div class="clear"></div>
<!-- Menu y Usuario init() -->
	<%@ include file="include/menuUsuario.jsp" %>
<!-- Menu y Usuario end() -->
<div class="clear"></div>
<!-- Formulario --> 
<div id="buscador">
<h2>Gesti<h:outputText value="#{msg.tilde_o}" />n de Concepto Estudio Socioecon<h:outputText value="#{msg.tilde_o}" />mico: <h:outputText value="#{empty estConceptoController.estConcepto.id ? 'NUEVO' : 'EDICION'}" /></h2>
<h:form id="manageEstConceptoForm">
	<script type="text/javascript">
		function fnSumSubTotales(id,rows){				    
			var peso =document.getElementById(id);	
			if( parseInt(peso.value) > -1){		
				var total =document.getElementById('manageEstConceptoForm:puntajeTotal');															
				var subTotal = id.substring(0,id.length-6);
				var fila = rows-1;
				subTotal = subTotal + fila;								
				subTotal = subTotal +':subTotal';			
				subTotal = document.getElementById(subTotal);				
				suma(subTotal,total,peso.value,subTotal.value);
			}			
		}

		function fnRestSubTotales(id,rows){		   		
			var peso =document.getElementById(id);
			if( parseInt(peso.value) > -1){
				var total =document.getElementById('manageEstConceptoForm:puntajeTotal');									
				var subTotal = id.substring(0,id.length-6);
				var fila = rows-1;
				subTotal = subTotal + fila;								
				subTotal = subTotal +':subTotal';			
				subTotal = document.getElementById(subTotal);				
				resta(subTotal,total,peso.value,subTotal.value);
			}
		}

		
		function suma(subTotal,total, peso, acumulado){
			subTotal.value = parseInt(peso) + parseInt(acumulado);
			total.value = parseInt(total.value) + parseInt(peso);
			var total1 =document.getElementById('manageEstConceptoForm:puntajeTotal1');
			total1.value=total.value;
			
		}
		function resta(subTotal,total, peso, acumulado){
			subTotal.value = parseInt(acumulado) - parseInt(peso);
			total.value = parseInt(total.value) - parseInt(peso);
			var total1 =document.getElementById('manageEstConceptoForm:puntajeTotal1');
			total1.value=total.value;
		}


		function fnNo(valor,id,rows){
			if(valor == 'N'){
				var total1 =document.getElementById('manageEstConceptoForm:puntajeTotal1');
				var total =document.getElementById('manageEstConceptoForm:puntajeTotal');																							
				var name = id.substring(0,id.length-6);
				var subTotal = id.substring(0,id.length-8);			
				var fila = rows-1;
				subTotal = subTotal + fila;								
				subTotal = subTotal +':subTotal';					
				subTotal=document.getElementById(subTotal);									
				name = name +'peso';
				name=document.getElementById(name);				
				total.value = parseInt(total.value) - parseInt(name.value);
				total1.value=total.value;	
				subTotal.value = parseInt(subTotal.value) - parseInt(name.value);
				name.value='0';
			}

			function soloNumeros(e)
			{
			 var key;
			 alert("0");
			 
			 alert(key);
			 if (key < 48 || key > 57)
			    {
			      return false;
			    }
			 return true;
			}		
		}
	</script>
				<div class="clear"></div>    			   				
						<span class="left">
						<label>Estado <span class="asterisco">*</span></label>							
					    	<h:selectOneMenu id="estado" styleClass="validate[required]"
							value="#{estConceptoController.estConcepto.estado}" >
                                <f:selectItem itemLabel="Seleccione..." itemValue=""/>
                                <f:selectItem itemLabel="Completo" itemValue="COMPLETO"/>
                                <f:selectItem itemLabel="Incompleto" itemValue="INCOMPLETO"/>                                                                
                            </h:selectOneMenu>											
						</span>		
					<div class="clear"></div>
					<br/>   						   
						<span class="left" >
						<label>Puntaje Total</label>
								<h:inputText readonly="true"  id="puntajeTotal" styleClass="validate[min[1]]" size="9" maxlength="9" 
										value="#{estConceptoController.estConcepto.puntajeTotalStr}" />													
							<a4j:commandButton id="checkEstado"											 
							                 type="submit" 
							                 value="Verificar..." ajaxSingle="true" 
							                 ondblclick="return false;" reRender="checkEstadoPanel"
					                         action="#{estConceptoController.verificarEstadoConcepto}" >					                         
					                         <a4j:actionparam name="puntajeParam" value="document.getElementById('manageEstConceptoForm:puntajeTotal').value" 
					                                          assignTo="#{estConceptoController.estConcepto.puntajeTotalStr}" noEscape="true" />
							</a4j:commandButton>
						</span>						
						<span class="right">						
						<a4j:outputPanel id="checkEstadoPanel" layout="block" >
							<h:panelGrid columns="1" style="text-align: left;" styleClass="tablapaginacion" >
							<h:outputText value="Estado Socioecon#{msg.tilde_o}mico: #{estConceptoController.estConcepto.strEstadoSocioEco}"/>							
	                        </h:panelGrid>
                        </a4j:outputPanel>										
						</span>						
				<br/>
				<div class="clear"></div>		
				<rich:dataTable id="estConceptoData" styleClass="scrollerTable" headerClass="standardTable_Header"
					                border="0" cellpadding="3" cellspacing="1" 
					                footerClass="standardTable_Header" rowKeyVar="rowIndex"
      		                rowClasses="tablamultiregistrotr1,tablamultiregistrotr2"
      		                onRowMouseOver="this.style.backgroundColor='#C0C0C0'"
      					          onRowMouseOut="this.style.backgroundColor='#FFFFFF'"
					                var="estConceptoRow" value="#{estConceptoController.clasificacionListModel}" >
				         	  <h:column>					               
					               <h:outputText value="C#{msg.tilde_o}digo" />					               		                   
					           </h:column>						           
					           <h:column>					               
					               <h:outputText value="#{estConceptoRow.nombreVariable}"/>		                    
					           </h:column>	
					           <h:column>					               
					          		<h:outputText value="Si/No"/>					          		
					           </h:column>						  
					           <h:column>					               
					          			<h:outputText value="Puntos"/>					               		                   
					           </h:column>						  					                    
      				 <rich:subTable
                        onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
                        onRowMouseOut="this.style.backgroundColor='#FFFFFF'"
                        var="detalle" value="#{estConceptoRow.caracteristicas}">
                        <rich:column>
                            <h:outputText value="#{detalle.codigo}"></h:outputText>
                            <f:facet name="footer">
                                <rich:spacer />
                            </f:facet>
                        </rich:column>
                        <rich:column>
                            <h:outputText value="#{detalle.nombreCaracteristica}"></h:outputText>
                            <f:facet name="footer">
                                <rich:spacer />
                            </f:facet>
                        </rich:column>
                        <rich:column>
                            <h:selectOneMenu id="aplica" onchange="fnNo(this.value,this.id,#{estConceptoRow.nroRegistros})" styleClass="validate[required]"
								   value="#{detalle.aplica}" >
				                   <f:selectItem itemLabel="Seleccione..." itemValue=""/>	
				                   <f:selectItem itemLabel="Si" itemValue="S"/>	
				                   <f:selectItem itemLabel="No" itemValue="N"/>				                   
				              	</h:selectOneMenu>
							<f:facet name="footer">                                
                                <h:outputText value="Subtotal"/>
                            </f:facet>				              		
                        </rich:column>
						<rich:column>                                                                           
									<h:inputText id="peso" onblur="fnSumSubTotales(this.id,#{estConceptoRow.nroRegistros})" onfocus="fnRestSubTotales(this.id,#{estConceptoRow.nroRegistros})" value="#{detalle.pesoStr}" styleClass="validate[custom[integer],min[0],max[#{detalle.pesoMax}]]" size="9" maxlength="2">								         
								   </h:inputText>
							<f:facet name="footer">								    
								<h:inputText id="subTotal" readonly="true" value="#{estConceptoRow.subTotalStr}" size="9"></h:inputText> 								
                            </f:facet>								   
						</rich:column>   													 			   													 								                                         
                    </rich:subTable>
        	  </rich:dataTable>
				<div class="clear"></div>	        					 						  
						<span class="left" >
						<label>Puntaje Total</label>
								<h:inputText readonly="true"  id="puntajeTotal1" styleClass="validate[min[1]]" size="9" maxlength="9" 
										value="#{estConceptoController.estConcepto.puntajeTotalStr}" />													
							<a4j:commandButton id="checkEstado1"											 
							                 type="submit" 
							                 value="Verificar..." ajaxSingle="true" 
							                 ondblclick="return false;" reRender="checkEstadoPanel1"
					                         action="#{estConceptoController.verificarEstadoConcepto}" >					                         
					                         <a4j:actionparam name="puntajeParam" value="document.getElementById('manageEstConceptoForm:puntajeTotal').value" 
					                                          assignTo="#{estConceptoController.estConcepto.puntajeTotalStr}" noEscape="true" />
							</a4j:commandButton>
						</span>						
						<span class="right">						
						<a4j:outputPanel id="checkEstadoPanel1" layout="block" >
							<h:panelGrid columns="1" style="text-align: left;" styleClass="tablapaginacion" >
							<h:outputText value="Estado Socioecon#{msg.tilde_o}mico: #{estConceptoController.estConcepto.strEstadoSocioEco}"/>							
	                        </h:panelGrid>
                        </a4j:outputPanel>										
						</span>						        
		    						
				<div class="clear"></div>    
		<div class="clear"></div>
		(<span class="asterisco"> * </span>) : Campo Obligatorio
		<div class="clear"></div>
		<span class="botones right">
		<h:commandButton id="createEstConceptoButton"						 
             type="submit" 
             value="Guardar" 
             ondblclick="return false;" 
             action="#{estConceptoController.manage}" >
		</h:commandButton>
		</span>
</h:form>
</div>
<!-- Fin formulario --> 
				<div class="clear"></div>
				<div class="clear" style="width: 400px; margin-left: 0px;"></div>
				<div class="clear" style="margin-left: 350px;"></div>
				<span class="botones left" style="width: 223px; height: 15px; margin-left:25px; padding-top:5px; padding-bottom:5px; padding-left:20px; padding-right:20px; background-color: #006F73; color: white;">
				Informaci<h:outputText value="#{msg.tilde_o}" />n de Auditor<h:outputText value="#{msg.tilde_i}" />a
				</span>
				<div class="clear" style="margin-left: 350px;"></div>
				<div>
				<span class="left" >
				<span class="left" style="width: 110px; height: 15px; margin-left:25px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; background-color: #EDEDED; border-top: 1px solid #999999; border-bottom: 1px solid #999999; border-left: 1px solid #999999; border-right: 1px solid #999999; color: #666666;">Usuario Creaci<h:outputText value="#{msg.tilde_o}" />n</span>
				<span class="left" style="width: 110px; height: 15px; margin-left:0px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; background-color: #EDEDED; border-top: 1px solid #999999; border-bottom: 1px solid #999999; border-left: 0px solid #999999; border-right: 1px solid #999999; color: #666666;">Fecha Creaci<h:outputText value="#{msg.tilde_o}" />n</span>
				<span class="left" style="width: 170px; height: 15px; margin-left:0px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; background-color: #EDEDED; border-top: 1px solid #999999; border-bottom: 1px solid #999999; border-left: 0px solid #999999; border-right: 1px solid #999999; color: #666666;">Usuario <h:outputText value="#{msg.tilde_u}" />ltima Modificaci<h:outputText value="#{msg.tilde_o}" />n</span>
				<span class="left" style="width: 170px; height: 15px; margin-left:0px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; background-color: #EDEDED; border-top: 1px solid #999999; border-bottom: 1px solid #999999; border-left: 0px solid #999999; border-right: 1px solid #999999; color: #666666;">Fecha <h:outputText value="#{msg.tilde_u}" />ltima Modificaci<h:outputText value="#{msg.tilde_o}" />n</span>
				</span>		
				<span class="left" >
				<span class="left" style="width: 110px; height: 15px; margin-left:25px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; background-color: #ffffff; border-top: 0px solid #999999; border-bottom: 1px solid #999999; border-left: 1px solid #999999; border-right: 1px solid #999999; color: #666666;"><h:outputText value="#{estConceptoController.estConcepto.usuarioCrea}" /></span>
				<span class="left" style="width: 110px; height: 15px; margin-left:0px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; background-color: #ffffff; border-top: 0px solid #999999; border-bottom: 1px solid #999999; border-left: 0px solid #999999; border-right: 1px solid #999999; color: #666666;"><h:outputText value="#{estConceptoController.estConcepto.fechaCrea}" /></span>
				<span class="left" style="width: 170px; height: 15px; margin-left:0px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; background-color: #ffffff; border-top: 0px solid #999999; border-bottom: 1px solid #999999; border-left: 0px solid #999999; border-right: 1px solid #999999; color: #666666;"><h:outputText value="#{estConceptoController.estConcepto.usuarioModifica}" /></span>
				<span class="left" style="width: 170px; height: 15px; margin-left:0px; padding-top:5px; padding-bottom:5px; padding-left:10px; padding-right:10px; background-color: #ffffff; border-top: 0px solid #999999; border-bottom: 1px solid #999999; border-left: 0px solid #999999; border-right: 1px solid #999999; color: #666666;"><h:outputText value="#{estConceptoController.estConcepto.fechaModifica}" /></span>
				</span>
		    </div>
        <span>
			    <h:form id="cancelManageForm">
    					<h:commandButton id="cancelManageButton"
    						 
                 type="submit" 
                 value="Cancelar" 
                 ondblclick="return false;" 
                 action="#{estConceptoController.cancelEstConcepto}" >
             </h:commandButton>
           </h:form>
		</span>
	<div id="containerError" style="display:block;">
		<span class="botones left"><h:messages style="font-weight: bold; color: #FF0000;" /></span>
	</div>
    </div>
	<div class="abajo-cuerpo"></div> 
	</div> <!-- Fin contenedor -->
	<div class="footer"></div>	
<script src="<%=contextRoot%>/js/jquery/lib/jquery-1.7.2.min.js"></script><!-- De ser 1ro -->
<script src="<%=contextRoot%>/js/script.js" type="text/javascript"></script><!-- De ser 2do -->
<script src="<%=contextRoot%>/js/jquery/lib/jquery.uniform.min.js"></script> <!-- formularios --> 
<script src="<%=contextRoot%>/js/jquery/lib/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=contextRoot%>/js/jquery/lib/jquery.validationEngine-es.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=contextRoot%>/js/jquery.maskedinput-1.3.js" type="text/javascript"></script> <!-- Quitar si no se usan fechas -->
<script src="<%=contextRoot%>/js/sisdep.js" type="text/javascript"></script> <!-- Quitar si no se usan funciones custom -->
<script type="text/javascript">
jQ(document).ready(function() {
	jQ("input, select, input:checkbox, input:radio, input:file").uniform();
	jQ("#manageEstConceptoForm").validationEngine('attach');
	jQ("#manageEstConceptoForm").bind("jqv.form.result", function(event, errorFound) {
        if(!errorFound) displayLoadingImage();
    });
  // Activar la mascara para CADA campo tipo fecha. En caso de NO tener quitar esta linea:
  // jQ(".fechaXX").mask("99/99/9999");
});
</script>
<%@ include file="include/validationStatus.jsp" %>
</body>
</html>
</f:view>
